<%--
  Created by IntelliJ IDEA.
  User: dream
  Date: 2017-1-10
  Time: 10:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>注册页面</title>
</head>
<body>

<form name="loginForm" method="post">
    <table>
        <tr>
            <td>用户名:<input type="text" name="userName" id="userName"></td>
        </tr>
        <tr>
            <td>密码:<input type="password" name="password" id="password"></td>
        </tr>
        <tr>
            <td>确认密码:<input type="password" name="password" id="passwordConfirm"></td>
        </tr>
        <tr>
            <td><input id="sub" type="button" name="Submit" value="提交信息" style="background-color:grey">   <input type="button"name="btn"value="返回上一页"style="background-color:grey"></td>
        </tr>
    </table>
</form>

</body>
</html>
<script>
    (function(){
        var sub = document.getElementById("sub");
        //初始化移入移出事件
        if(sub.addEventListener){
            sub.addEventListener("click", test);
        }else if(sub.attachEvent){
            sub.attachEvent("onClick", test);
        }
    })();

    function test(){
        var password = document.getElementById("password");
        var passwordConfirm = document.getElementById("passwordConfirm");
        if(password.value != passwordConfirm.value)
            alert("对不起，您2次输入的密码不一致");
        else
            document.forms[0].submit();

    }
</script>
